<?php

namespace App\Admin;

use Illuminate\Database\Eloquent\Model;

class Auth extends Model
{
    //定义关联的数据表
    protected $table = 'auth';
    //禁用时间字段
    public $timestamps = false;

    // 无限级分类
    public function getSubTree($data) {

        function curl ($data , $id = 0 , $lev = 0) {
            static $son = array();

            foreach($data as $key => $value) {
                if($value['pid'] == $id) {
                    $value['lev'] = $lev;
                    $son[] = $value;
                    curl($data , $value['id'] , $lev+1);
                }
            }
             return $son;
        }
        return curl($data);
        
    }  
}
